<?php include $this->header();?>
<script type="text/javascript" src="js/uploader/swfupload.js"></script>
<script type="text/javascript" src="js/uploader/queue.js"></script>
<script type="text/javascript" src="js/uploader/fileprogress.js"></script>
<script type="text/javascript" src="js/uploader/handlers.js"></script>
<script type="text/javascript" src="js/uploader/lang/zh-cn.js"></script>
<script type="text/javascript" src="js/uploader/uploader.js"></script>
<?php if(false) {?>
<link rel="stylesheet" rev="stylesheet" href="../../../images/admincp/style.css" type="text/css" media="all" />
<?php }?>
<div class="wrap">
<form method="post" enctype="multipart/form-data" target="_self" onsubmit="return Validator.Validate(this)">
<div class="bd p1 mt">
    <ul class="tabs">
        <li><a href="javascript:;" id="tab-1">基本选项</a></li>
        <li><a href="javascript:;" id="tab-2">SEO</a></li>
    </ul>
    <div class="panes">
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="rank">
        <tr>
            <td colspan="3" align="right" valign="middle" style="height:1px; line-height:1px; overflow:hidden;border:none;">&nbsp;</td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">标题</td>
            <td colspan="2"><input name="product_title" type="text" class="text-box" id="product_title" onblur="Validator.check(this)" value="<?=$item['product_title']?>" size="60" dataType="LimitB" min="8" max="80" msg="请填写4-40个中文字符，8-80个英文字符" /> 
                <b class="red">* </b>
                <span class="note">建议使用主题相关的关键词。</span>
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">分类</td>
            <td colspan="2">
              <select name="cat_id" id="cat_id">
                  <?php foreach ($this->_cats as $_cat) {?>
                  <option value="<?=$_cat['cat_id']?>" <?php if($item['cat_id'] == $_cat['cat_id']){?>selected="selected"<?php }?>><?=$_cat['icon']?><?=$_cat['cat_name']?></option>
                  <?php }?>                  
              </select>
              <span class=" note">不选择则为默认分类，若没有您想要的分类，请到"分类管理"→"添加分类"中添加您想要的分类</span></td>
        </tr>
        <tr>
            <td align="right" valign="middle">品牌</td>
            <td colspan="2">
              <select name="brand_id" id="brand_id">
                <option>请选择品牌</option>
              </select>
              <span class=" note">若没有您想要的品牌，请到"品牌管理"→"添加品牌"中添加您想要的品牌</span>
            </td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">商品编号</td>
            <td colspan="2"><input name="product_sn" type="text" class="text-box" id="product_sn" value="<?=$item['product_sn']?>" size="12"  /> 
                <span class="note">如果您不输入商品编号，系统将自动生成一个唯一的货号，建议由系统自动生成</span>
            </td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">市场价格</td>
            <td colspan="2"><input name="product_market_price" type="text" class="text-box" id="product_market_price" value="<?=$item['product_market_price']?>" size="12"  /> 
                <span class="note">若您不输入市场价格，系统将自动计算一个市场价格，=销售价格x1.1，小数点第二位四舍五入</span>
            </td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">销售价格</td>
            <td colspan="2"><input name="product_price" type="text" class="text-box" id="product_price" value="<?=$item['product_price']?>" size="12"  /> 
                <span class="note">单位为元</span>
            </td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">销售单位</td>
            <td colspan="2">
              <input name="product_sale_unit" type="text" class="text-box" id="product_sale_unit" value="<?=$item['product_sale_unit']?>" size="12"  />
              <select name="product_unit_options" id="product_unit_options">
                <option>选择单位</option>
                <option value="盒">盒</option>
                <option value="包">包</option>
                <option value="箱">箱</option>
                <option value="件">件</option>
                <option value="瓶">瓶</option>
                <option value="桶">桶</option>
                <option value="台">台</option>
                <option value="块">块</option>
              </select>            
              <span class="note">本项可可以填写亦可选择已有单位，如500毫升一瓶的牛奶，则填写瓶</span>
            </td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">商品规格</td>
            <td colspan="2">
              <input name="product_spec" type="text" class="text-box" id="product_spec" value="<?=$item['product_spec']?>" size="12"  />
              <select name="product_measure_unit" id="brand_id">
                <option value="" <?php if(empty($item['product_measure_unit'])){?> selected="selected"<?php }?>>计量单位</option>
                <option value="盒" <?php if($item['product_measure_unit']=='盒'){?> selected="selected"<?php }?> >盒</option>
                <option value="包" <?php if($item['product_measure_unit']=='包'){?> selected="selected"<?php }?> >包</option>
                <option value="箱" <?php if($item['product_measure_unit']=='箱'){?> selected="selected"<?php }?> >箱</option>
                <option value="件" <?php if($item['product_measure_unit']=='件'){?> selected="selected"<?php }?> >件</option>
                <option value="瓶" <?php if($item['product_measure_unit']=='瓶'){?> selected="selected"<?php }?> >瓶</option>
                <option value="桶" <?php if($item['product_measure_unit']=='桶'){?> selected="selected"<?php }?> >桶</option>
                <option value="台" <?php if($item['product_measure_unit']=='台'){?> selected="selected"<?php }?> >台</option>
                <option value="块" <?php if($item['product_measure_unit']=='块'){?> selected="selected"<?php }?> >块</option>
              </select>                
              <span class="note">第一个输入框只能填写数字，后面这个选择单位，如500毫升一瓶的牛奶，则填写500，选"毫升"</span>
            </td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">积分</td>
            <td colspan="2"><input name="product_score" type="text" class="text-box" id="product_score" value="<?=$item['product_score']?>" size="12"  />                
            <span class="note">如果您不输入所得积分，则系统将自动计算一个积分，积分=销售价格，舍去小数点取整</span>
            </td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">产品图片</td>
            <td align="left" valign="middle" class="">
                <div class="note">点击图片设为封面，图片尺寸建议600*600</div> 
                <div id="post-photos">
                    
                </div>    
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">详细内容</td>
            <td colspan="2"><textarea id="product_content" class="product_content" name="product_content" rows="26" style="width:99%; " ><?=$item['product_content']?></textarea></td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">规格参数 </td>
            <td colspan="2"><textarea name="product_specs" cols="45" rows="5" id="product_specs"><?=$item['product_specs']?>
            </textarea></td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">包装清单 </td>
            <td colspan="2"><textarea name="product_packing_list" cols="45" rows="5" id="product_packing_list"><?=$item['product_packing_list']?>
            </textarea></td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">责任编辑</td>
            <td colspan="2"><input name="product_editor" type="text" class="text-box" id="product_editor" value="<?=$item['product_editor']?>" size="45" /></td>
        </tr>
        <tr>
            <td align="right" valign="middle">货物类型</td>
            <td colspan="2">
              <input name="product_is_sale" value="1" <?php if($item['product_is_sale']){?>checked="checked"<?php }?> type="checkbox" id="product_is_sale" />商品
              <input name="product_is_present" value="1" type="checkbox" id="product_is_present" <?php if($item['product_is_present']){?>checked="checked"<?php }?> />赠品 
              <span class="note">可同时打钩，既是商品又是赠品；一般情况下，若该商品不属于赠品，请不要打钩</span>
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">是否上架</td>
            <td colspan="2">
              <input name="product_status" value="1" <?php if($item['product_status'] == 1){?>checked="checked"<?php }?> type="radio" />是
              <input name="product_status" value="0" type="radio" <?php if($item['product_status'] == 0){?>checked="checked"<?php }?> />
              否 <span class="note">&nbsp;</span>
              <input name="product_status" value="-1" type="radio" <?php if($item['product_status'] == -1){?>checked="checked"<?php }?> />
              回收站
              <span class="note">&nbsp;</span></td>
        </tr>
        <tr>
            <td align="right" valign="middle">排序</td>
            <td colspan="2"><input name="product_order" type="text" class="text-box" id="product_order" value="<?=$item['product_order']?>" size="4" /></td>
        </tr>
        <tr>
            <td align="right" valign="middle" class="nobd">&nbsp;</td>
            <td colspan="2" class="nobd"><input class="btn" type="submit" value="提交" />
                <input name="重置" type="reset" class="btn" value="重置" /></td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="rank">
        <tr>
            <td colspan="2" align="right" valign="middle" style="height:1px; line-height:1px; overflow:hidden; border:none;">&nbsp;</td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">页面标题</td>
            <td><input name="product_slug" type="text" class="text-box" id="product_slug" value="<?=urldecode($item['product_slug'])?>" size="63" />
                <span class="note">(留空则默认使用商品名称)</span>
            </td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">页面关键词</td>
            <td><input name="product_keywords" type="text" class="text-box" id="product_keywords" value="<?=$item['product_keywords']?>" size="63" /> <span class="note">(留空则默认继承分类或全局设置的KEYWORDS内容)</span></td>
        </tr>
        <tr>
            <td width="140" align="right" valign="middle">页面摘要</td>
            <td>
                <textarea name="product_desc" id="product_desc" cols="60" rows="6"><?=$item['product_desc']?>
                </textarea> <span class="note"> (留空则默认继承分类或全局设置的DESCRIPTION内容)</span>
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle" class="nobd">&nbsp;</td>
            <td class="nobd"><input class="btn" type="submit" value="提交" />
                <input name="重置" type="reset" class="btn" value="重置" /></td>
        </tr>
      </table>
    </div>
</div>
</form>
</div>

<script type="text/javascript" src="js/editor.js"></script>
<script type="text/javascript">
//<![CDATA[
function setCover(id) {  
/*  
	if($('#'+id).parent().find('input').val() == '') {
		return false;
	}
	*/
	$('#product_cover').val(id);
	$('.thumb.checked').removeClass('checked');
	$('#'+id).addClass('checked');
}

$.ajaxf.ready(function(){
    $("ul.tabs").tabs("div.panes > table");
	var params = {"<?=session_name()?>":'<?=session_id()?>', 'user_id':'<?=$_SESSION['user_id']?>', 'upload_rid':'<?=$item['product_id']?>', 'upload_app':'<?=$app?>', 'upload_type':'content'};
    ueEditor.apply('#product_content', params);
	params.upload_type = 'album';
	var opts = {cover_rid : '<?=$item['product_cover_rid']?>'};
	albumEdit('post-photos', params, 'product_cover_rid', 'product_cover_img', opts);

	
	$('#product_unit_options').change(function(){
		$('#product_sale_unit').attr('value', $(this).attr('value'));
	}),

	$('#cat_id').change(function(){
		ajaxStatusStop();
		var opts = '<option>请选择品牌</option>';
		var catId = $('#cat_id').val();
		if(catId >= 0) {
			ajaxStatusStart();
			$.ajaxf.getJSON('index.php?product/show/getBrandsByCatId/'+catId, Math.random(), function(r) {
				for(var i in r) {
					opts += '<option id="brand-list-' + r[i].brand_id+'" value="' + r[i].brand_id+'" '+ (r[i].brand_id == <?=$item['brand_id']?> ? 'selected="selected"' : "")+'>' + r[i].brand_name+'</option>';
				}
				
			    $('#brand_id').html(opts);
				<?php if($item['brand_id']):?>
				$('#brand-list-<?=$item['brand_id']?>').attr('checked', 'checked');
				<?php endif;?>
				ajaxStatusStop();
				return true;
			});
		}
		$('#brand_id').html(opts);
	});
	<?php if($item['brand_id']):?>
	$('#cat_id').change();
	<?php endif;?>
});
//]]>
</script>
<?php include $this->footer();?>
